﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Problem1
{
    class ObjectPool
    {
        private List<AbstractCar> list;
        static private ObjectPool objPool;
        private ObjectPool()
        {
            list = new List<AbstractCar>();
        }
        public static ObjectPool getInstance()
        {
            if (objPool == null)
                objPool = new ObjectPool();
            return objPool;
        }

        public AbstractCar checkOut(String model, String culoare)
        { 
            foreach(AbstractCar  car in list)
                if (car.ToString().Contains(model) && car.ToString().Contains(culoare))
                {
                    return car;
                }
            return null; 
        }
        public void checkIn(AbstractCar car)
        {
            list.Add(car);
        }
    }
}
